home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 18 / fpc103.zip / MACROS.SEQ < prev    next >
Text File  |  1988-06-20  |  5KB  |  148 lines

  1. \ MACROS.SEQ    Keyboard macros for F-PC                  by Tom Zimmer
  2.  
  3. anew macros
  4.  
  5. comment:
  6.                         Keyboard macros for F-PC.
  7. To DEFINE a macro;
  8.         Press Alt-M             \ starts defining, waits for next key
  9.         Press Alt-1             \ tells it which macro to make, can be
  10.                                 \ Alt-1 through Alt-5, waits for first
  11.                                 \ key of macro
  12.         Start entering keys.    \ keys are passed on to program and saved too
  13.         Press Alt-M             \ Ends definition of the new macro
  14.         Thats all there is to MAKING macros.
  15.  
  16. To PERFORM a macro;
  17.         Press Alt-1             \ Macro processor passes back all keys
  18.                                 \ one for each call to key until empty
  19.         Thats all there is to DOING macros.
  20.  
  21. To REPEAT a macro;
  22.         Press Alt-R             \ We will be repeating a macro key
  23.         Enter a # between 0-999 \ The number of times to repeat the macro
  24.         Press Alt-1             \ the macro to repeat.
  25. comment;
  26.  
  27. only forth also hidden also definitions
  28.  
  29. 248 constant macbase            \ Alt-1
  30.  10 constant #macros            \ Through Alt-0
  31. \ 187 constant macbase            \ F1
  32. \  10 constant #macros            \ Through F10
  33.  
  34. 128 constant macsiz
  35.   0 constant macseg
  36.  
  37. : ms:           ( n1 --- seg n1 )
  38.                 macseg swap ;
  39.  
  40. : macreset      ( --- )                 \ Clear macros segment pointer.
  41.                 defers initstuff
  42.                 0 =: macseg ;
  43.  
  44. ' macreset is initstuff
  45.  
  46. : macinit       ( --- )
  47.                 macseg if exit then
  48.                 #macros macsiz * u16/ alloc
  49.                 if      2drop exit
  50.                 then    nip =: macseg
  51.                 macseg 0 #macros macsiz * 0 lfill ;
  52.  
  53. variable curmac
  54. variable doingmac
  55. variable makingmac
  56.  
  57. : .makemac      ( --- )
  58.                 #out @ #line @ >r >r
  59. 25 07 .box" Making a MACRO."
  60. 08 10 .box" Press Alt-1 to Alt-9 to specify the macro you are making."
  61. 17 13 .box" Enter the keys of your macro, then;"
  62. 13 16 .box" Press Alt-M again to finish building a macro."
  63.                 r> r> at ;
  64.  
  65. : .repmac       ( --- )
  66. 25 07 .box" Repeating a MACRO."
  67. 01 10 .box" Enter a # between 000 and 999 for the number of times to repeat the macro."
  68. 30 13 .box"         "
  69. 17 16 .box" Enter the macro key Alt-1 to Alt-9"
  70. 32 14 at ;
  71.  
  72. : setmac        ( n1 --- )      \ set the current macro pointer.
  73.                 macsiz * curmac ! ;
  74.  
  75. : ?domac        ( --- <c1> )    \ Are we doing a macro, if so return a key.
  76.                 doingmac @
  77.                 if      curmac @ ms: c@l curmac @ 1+ ms: c@l 0=
  78.                         if      doingmac off
  79.                         then    curmac incr r> r> 2drop
  80.                 then    ;
  81.  
  82. : ?domac1       ( c1 --- c2 )   \ If a macro key, start macro and return
  83.                                  \ the first macro key if its good.
  84.                 dup macbase dup #macros 1- + BETWEEN
  85.         if      doingmac on macbase - setmac
  86.                 curmac @ ms: c@l curmac incr ?dup 0=
  87.                 if      doingmac off
  88.                         curmac @ 1- macsiz / macbase +
  89.                 then
  90.         then    ;
  91.  
  92. variable mactimes       \ number of times to perform a macro
  93. variable repkey         \ macro key we are repeating
  94.  
  95. : ?repmac       ( --- <c1> )
  96.                 mactimes @
  97.                 if      mactimes decr
  98.                         repkey @ ?domac1 r> r> 2drop
  99.                 then    ;
  100.  
  101. : ?repmac1      ( c1 --- c1 )
  102.                 dup 147 = makingmac @ 0= and    \ Alt-R = repeating
  103.                 if      drop savescr #out @ #line @ >r >r .repmac
  104.                         0
  105.                         begin   defers key dup ascii 0 ascii 9 between
  106.                         while   dup emit ascii 0 - swap 10 * + 999 min
  107.                         repeat  restscr r> r> at
  108.                         swap 1- 0 max 999 min mactimes !
  109.                         dup repkey !
  110.                 then    ;
  111.  
  112. : ?addmac       ( c1 --- c1 )   \ conditionally add a key to current macro.
  113.                 makingmac @
  114.                 if      dup curmac @ ms: c!l curmac incr 0 curmac @ ms: !l
  115.                 then    ;
  116.  
  117. : ?start/stopmac ( --- c1 )     \ Conditionally start of stop making a macro.
  118.                 begin   defers key
  119.                         dup 178 = makingmac @ 0= and    \ Alt-M = Make macro
  120.                         if      drop savescr .makemac
  121.                                 defers key restscr     \ Alt-1 to Alt-5
  122.                                 dup macbase dup #macros 1- +
  123.                                 BETWEEN 0=              \ macro key number
  124.                                 if      exit
  125.                                 then    macbase - setmac 0 curmac @ ms: !l
  126.                                 makingmac on
  127.                                 defers key
  128.                         then    dup 178 = makingmac @ and \ Alt-M and making
  129.                 while   drop makingmac off
  130.                 repeat  ;
  131.  
  132.  
  133. : mackey        ( --- c1 )      \ This definition looks more like PASCAL
  134.                 macinit macseg 0=
  135.                 if      defers key
  136.                 else    ?domac  ?repmac  ?start/stopmac
  137.                         ?addmac ?repmac1 ?domac1
  138.                 then    ;
  139.  
  140.  
  141. \ Alt-1 = 248, to Alt-5 = 252
  142.  
  143. ' mackey is key
  144.  
  145. only forth also definitions
  146.  
  147.  
  148.